package com.example.shop_2207.net

import com.example.shop_2207.entity.*
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Query

interface ApiServer {

    //使用协程进行后台请求--定义的函数需要时挂起的
    @POST(Cons.LOGIN_URL)
    suspend fun login(@Body body: RequestBody): UserEntityResult

    @POST(Cons.REGISTER_URL)
    suspend fun register(@Body body: RequestBody): UserEntityResult

    @GET(Cons.BANNER_URL)
    suspend fun banner(): BannerEntityResult

    @GET(Cons.CATEGORY_URL)
    suspend fun cate(): CategoryEntityResult
    @GET(Cons.GOODS_URL)
    suspend fun goods(
        @Query("category_id") category_id: Int,
        @Query("currentPage") currentPage: Int,
        @Query("pageSize") pageSize: Int
    ):GoodsEntityResult

    @GET(Cons.DETAIL_URL)
    suspend fun detail(@Query("goods_id")goods_id:Int):DetailEntityResult

    @POST(Cons.ADDCAR_URL)
    suspend fun addCar(@Body body: RequestBody):ResultEntity
    @GET(Cons.SELECTCAR_URL)
    suspend fun selectCar():CarEntityResult
    @POST(Cons.DELETECAR_URL)
    suspend fun deleteCar(@Body body: RequestBody):ResultEntity
    @Multipart//参数类型为文件时使用
    @POST(Cons.UPDATEICON_URL)
    suspend fun updateIcon(@Part part: MultipartBody.Part):ResultEntity
}